# -*- coding: utf-8 -*-
"""
Created on Thu Sep 12 16:32:39 2019

@author: Administrator
"""

# 1032 挖掘机技术哪家强
# 使用dict存储数据，学校编号为key，成绩为value
# 遍历dict找到最大值的成绩及学校编号
# 运行超时 O(n)
"""
import time
def test():
    num = int(input())
    data = dict()
    
    for i in range(num):
        temp = input().split(' ')
        if data.get(temp[0]) == None:
            data[temp[0]] = int(temp[1])
        else:
            data[temp[0]] = data[temp[0]] + int(temp[1])
            
#    print(data)
    # 求最大值
    max_value = 0
    max_index = 0
    for index,value in data.items():
        if value > max_value:
            max_value = value
            max_index = index
    print(max_index, max_value)
    
start = time.clock()
test()
end = time.clock()
print("Time used:", end - start)
"""
"""
def test():
    num = int(input())
    # 采用空间换时间
    data = []
    for i in range(10 ** 5 + 1):
        data.append(0)
    
    max_value = 0
    max_index = 0
    
    for i in range(num):
        temp = input().split(' ')
        index = int(temp[0])
        value = int(temp[1])
        if data[index] == 0:
            data[index] = value
        else:
            data[index] = data[index] + value
        # 求最大值
        if data[index] > max_value:
            max_value = data[index]
            max_index = index

    print(max_index, max_value)

test()
"""
"""
def test():
    num = int(input())
    data = dict()
    max_value = 0
    max_index = 0
    for i in range(num):
        temp = input().split(' ')
        key = temp[0]
        value = int(temp[1])
        if key not in data:
            data[key] = value
        else:
            data[key] = data[key] + value
    # 求最大值
        if data[key] > max_value:
            max_value = data[key]
            max_index = key
    print(max_index, max_value)
    
test()
"""
# 判断时间复杂度：从两个极端的角度考虑：最坏、最好